{% extends "base.html" %}

{% block content %}
    <h1>User: {{ user.username }}</h1>

    <form action='/confirm_deletion/{{ user.username }}' method='POST'
        onsubmit='return confirm("Are you sure you want to delete your profile?");'>
        <button type='submit'> Delete profile </button>
    </form>


    <h2>My suggestions</h2>
    {% if current_user.username == user.username or current_user.username == admin %}
    <h3>Colums: Name-Comment-Edit-Remove</h3>
    {% endif %}

    {% for suggestion in suggestions %}
            <form style='display: inline' action='/edit/{{ suggestion.author.username }}/{{ suggestion.id }}' method='post'>

            {% if current_user.username != suggestion.author.username and current_user.username != admin %}
                <input disabled type='text' name='name' value='{{ suggestion.body }}'>
                {% if suggestion.comment != None and suggestion.comment != '' %}
                    <input disabled type='text' name='comment' value='{{ suggestion.comment }}'>
                {% else %}
                    <input disabled type='text' name='comment'>
                {% endif %}
            {% else %}

                <input type='text' name='name' value='{{ suggestion.body }}' required>
                {% if suggestion.comment != None and suggestion.comment != '' %}
                    <input type='text' name='comment' value='{{ suggestion.comment }}'>
                {% else %}
                    <input type='text' name='comment'>
                {% endif %}
            {% endif %}
            {% if current_user.username == suggestion.author.username or current_user.username == admin %}
            <button type='submit'> Save </button>
            {% endif %}
                </form>

            {% if current_user.username == suggestion.author.username or current_user.username == admin %}
                <form style='display: inline' action='/remove/{{ suggestion.author.username }}/{{ suggestion.id }}' method='post'>
                    <button type='submit'> Remove </button>
                </form>
            {% endif %}
            <br />
    {% endfor %}
    <hr>
{% endblock %}


<!-- EOF -->

